#include <stdio.h>
#define SIZE 10

int sum(int *start, int *end);

int main(void) {
    int marbles[SIZE] = {20, 10, 5, 39, 4, 16, 19, 26, 31, 20};
    printf("marbles[SIZE - 1] value: %d\n", marbles[SIZE - 1]);
    printf("marbles[SIZE - 1] address: %p\n", &(marbles[SIZE - 1]));
    printf("marbles + SIZE    address: %p\n", marbles + SIZE);
    printf("*(marbles + SIZE) value: %d\n", *(marbles + SIZE));
    
    long answer = sum(marbles, marbles + SIZE);
    printf("The total number of marbles is %ld.\n", answer);
    printf("The size of marbles is %zd bytes.\n", sizeof marbles);

    return 0;
}

int sum(int *start, int *end) {
    int total = 0;
    while (start < end)
        total += *start++;
    
    return total;
}
